/*
	Copyright (C) 2010 2011 Rémi Thebault

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <iostream>

#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <QTextCodec>
#include <QFile>
#include <QString>

#include <procycle/version.h>

#include "procycle.h"


int main(int argc, char *argv[])
{
	QApplication app(argc, argv);

	QString locale = QLocale::system().name();
	QTranslator translator;
		translator.load(QString(":/tr/procycle_")+locale);
	QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
	app.installTranslator(&translator);

	QFile styleFile (":/procycle.qss");
	if (styleFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
		QString styleSheet (styleFile.readAll());
		app.setStyleSheet(styleSheet);
	}

	QString desc = "ProCycle v";
	desc += PC::VERSION_STRING;
	desc += " - ";
	desc += QApplication::tr("A cycle diagram builder");
	QString copy = "Copyright (c) 2010 2011 Rémi Thebault";
	QString text1 = QApplication::tr("This program comes with ABSOLUTELY NO WARRANTY.");
	QString text2 = QApplication::tr("It is free software, and you are welcome to redistribute"
											" it under certain conditions.");
	QString text3 = QApplication::tr("See http://www.gnu.org/licenses/gpl-3.0-standalone.html for details.");
	std::cout << desc.toStdString() << std::endl;
	std::cout << copy.toStdString() << std::endl;
	std::cout << text1.toStdString() << std::endl;
	std::cout << text2.toStdString() << std::endl;
	std::cout << text3.toStdString() << std::endl;

	ProCycle pc (argc, argv);

	return app.exec();
}
